# -*- coding: UTF-8 -*-
from selenium import webdriver
from spidertools.commone_define import chromedriver_linux_path,chromedriver_win_path
import sys


def get_browser():
    if sys.platform.startswith('win'):
        chromedirver_path = chromedriver_win_path
    else:
        chromedirver_path = chromedriver_linux_path

    options = webdriver.ChromeOptions()
    options.add_experimental_option("prefs", {"profile.managed_default_content_settings.images": 2})  # 不加载图片,加快访问速度
    options.add_experimental_option('excludeSwitches', ['enable-automation'])  # 开发者模式
    # options.add_argument('--headless')  # 实现不弹窗
    options.add_argument('--disable-gpu')
    # browser = webdriver.Chrome(options=options, executable_path=chrome_dirver_path)

    browser = webdriver.Chrome(options=options, executable_path=chromedirver_path)
    browser.implicitly_wait(2)
    return browser
